package com.example.wm_mbp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.wm_mbp.model.Employee;
import com.example.wm_mbp.service.EmployeeService;
import com.example.wm_mbp.mapper.EmployeeMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author fzykd
* @description 针对表【employee(员工信息)】的数据库操作Service实现
* @createDate 2023-03-13 20:31:43
*/
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee>
    implements EmployeeService{


    @Override
    public IPage<Employee> getAllEmpPage(Page<Employee> page1, String name) {
        //条件构造器
        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("username",name);
        }
        queryWrapper.orderByAsc("username");

        Page page = baseMapper.selectPage(page1,queryWrapper);
        return page;
    }
}




